<template>
  <div>
    <div class="header-container">
      <div class="public-top-layout">
        <div class="top-layout w">
          <div class="wechat">
            <!-- if 有小程序 -->
            <div class="xcx" v-if="appinfo.wxqrcode">
              <Poptip word-wrap width="200" placement="bottom" padding="0">
                <span>小程序</span>
                <div class="api" slot="content">
                  <img :src="appinfo.wxqrcode" width="200" />
                </div>
              </Poptip>
            </div>
            <span class="vline"></span>
            <div class="mp">
              <Poptip word-wrap width="200" placement="bottom" padding="0">
                <span>公众号</span>
                <div class="api" slot="content">
                  <img :src="appinfo.wxappqrcode" width="200" />
                </div>
              </Poptip>
            </div>
          </div>
          <div class="login" v-if="userinfo">
            <span>您好,{{userinfo.telnum}}</span>
            <!-- <span class="logout" @click="logout">登出</span> -->
          </div>
          <div class="login" v-else>
            <router-link :to="{ name: 'login', params: {} }">注册/登录</router-link>
          </div>
        </div>
      </div>
      <div class="header-search">
        <div class="search w">
          <div class="logo" @click="backindex">
            <img :src="appinfo.applogo" alt />
          </div>
          <div class="search-input">
            <Input
              size="large"
              search
              enter-button
              placeholder="请输入关键词..."
              @on-search="onsearch"
              v-model="cname"
            >
              <Select v-model="sindex" slot="prepend" style="width: 80px" @on-change="schange">
                <Option checked value="0">全职</Option>
                <Option value="1">兼职</Option>
                <Option value="2">简历</Option>
                <Option value="3">企业</Option>
              </Select>
            </Input>
          </div>
          <div class="post">
            <router-link :to="{ name: 'recruit', params: {} }">我要发布</router-link>
          </div>
        </div>
      </div>
      <div class="header-menu">
        <div class="header w">
          <div class="menu">
            <router-link :to="{ name: 'index', params: {} }">首页</router-link>
            <router-link :to="{ name: 'companylist', params: {} }">全部企业</router-link>
            <router-link :to="{ name: 'recruitlist', params: {} }">全部招聘</router-link>
            <router-link :to="{ name: 'resumelist', params: {} }">全部简历</router-link>
            <router-link :to="{ name: 'partjoblist', params: {} }">全部兼职</router-link>
            <router-link :to="{ name: 'profile', params: {} }" v-if="userinfo">个人中心</router-link>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
export default {
  //  name: 'app-header',
  props: ["appinfo", "userinfo"],
  data() {
    return {
      cname: "",
      sindex: 0
    };
  },
  methods: {
    backindex() {
      this.$router.push({ path: "/" });
    },
    logout() {
      this.userinfo = {};
      localStorage.removeItem("user_info");
      localStorage.removeItem("login_time");
      // var t = window.location.href;
      // var u = t.substring(0, t.indexOf("#"));
      // window.location.href = u;
      console.log(this.userinfo);
    },
    onsearch(e) {
      console.log(e);
      if (this.sindex == 0) {
        this.$router.push({ name: "recruitlist", query: { cname: e } });
      } else if (this.sindex == 1) {
        this.$router.push({ name: "partjoblist", query: { cname: e } });
      } else if (this.sindex == 2) {
        this.$router.push({ name: "resumelist", query: { cname: e } });
      } else {
        this.$router.push({ name: "companylist", query: { cname: e } });
      }
    },
    schange(e) {
      console.log(e);
      this.sindex = e;
    }
  }
};
</script>
<style lang="scss" scoped>
.header-container {
  width: 100%;
  background-color: #fff;

  .public-top-layout {
    background-color: #f8f8f8;

    .top-layout {
      height: 24px;
      line-height: 26px;

      display: flex;
      justify-content: space-between;

      .wechat {
        display: flex;
        align-items: center;

        .mp {
          margin-left: 10px;
        }
      }
    }
  }

  .header-search {
    .search {
      display: flex;
      align-items: center;
      justify-content: space-between;
      height: 80px;

      .logo {
        height: 40px;
        display: flex;
        align-items: center;

        img {
          height: 50px;
        }
      }

      .search-input {
        width: 350px;

        
      }
      .post {
        background: #0c8;
        color: #fff;
        font-size: 20px;
        padding: 10px 50px;
      }
    }
  }

  .header-menu {
    width: 100%;
    height: 56px;
    background-color: #0c8;

    .header {
      height: 56px;
      display: flex;
      align-items: center;
      justify-content: space-between;

      .menu {
        color: #fff;
        font-size: 20px;
        font-weight: 550;

        a {
          margin-right: 30px;
          text-decoraction: none;
          color: #fff;
          letter-spacing: 1px;
        }
      }
    }
  }
}

.vline {
  display: inline-block;
  width: 1px;
  height: 12px;
  vertical-align: middle;
  background: #e0e0e0;
  margin: 0 10px;
}
a {
  text-decoraction: none;
  color: #fff
}

.ivu-input-search {
          background: #0c8 !important;
          border-color: #0c8 !important;
        }
</style>

